home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / CONTRSRC.ZIP / SRC / TYPEONE / ROTAZOOM.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-11-12  |  36.5 KB  |  1,261 lines

  1.  
  2. ;*************************************************
  3. ; ROTATIVE ZOOM (C) 1994 Type One / TFL-TDV Prod.
  4. ;*************************************************
  5.  
  6. INCLUDE PDFIK.INC ; DataFile Manager 
  7. INCLUDE VIDEO.INC ; Flamoot VGA SetUp
  8. INCLUDE PLAYINFO.INC ; Player structures
  9. INCLUDE KEYBOARD.INC ; Keyboard macros
  10.  
  11. ;-----------------------------------------
  12. ; Déclaration modèle mémoire
  13. .386
  14. DGROUP GROUP _DATA,_BSS
  15. ROTA_TEXT  SEGMENT DWORD PUBLIC USE16 'CODE'
  16.        ASSUME CS:ROTA_TEXT,DS:DGROUP
  17. ROTA_TEXT  ENDS
  18. _DATA  SEGMENT DWORD PUBLIC USE16 'DATA'
  19. _DATA  ENDS
  20. _BSS   SEGMENT DWORD PUBLIC USE16 'BSS'
  21. _BSS   ENDS
  22. ;-----------------------------------------
  23.  
  24. _DATA SEGMENT
  25.  
  26. ; Quelques constantes bien utiles ......
  27.  
  28. Larg = 160       ; hauteur de l'écran en pixels
  29. Haut = 80        ; largeur de l'écran en pixels
  30. Windowx = 160    ; largeur fenetre
  31. Windowy = 80     ; hauteur fenetre
  32.  
  33. Screen1 = 0
  34. Screen2 = (Larg*Haut/4)
  35. Screen3 = (Larg*Haut/4)*2
  36.  
  37. ;---------------------------------------------
  38.  
  39. ;-- donnees pattern --
  40. EXTRN _Datafile  : BYTE
  41. EXTRN _OfsinDta  : DWORD
  42. Picname   BYTE 'tipon.raw',0
  43. Picparam  PARAM_STRUC<2,_DATA,OFFSET _Datafile,OFFSET Picname,0,0,0,,,0>
  44.  
  45. EVEN
  46. ; rotation parameters
  47. Angle  WORD 0          ; angle de rotation
  48. Scalx  WORD 0          ; echelle en x (*256)
  49. Scaly  WORD 0          ; echelle en y (*256)
  50. Coordx WORD 0          ; coordonnee initiale x
  51. Coordy WORD 0          ; coordonnee initiale y
  52. Stepx  WORD 0          ; pas en x
  53. Stepy  WORD 0          ; pas en y
  54. Yptr   WORD 0          ; pointeur sinus en y
  55. Xptr   WORD 0          ; pointeur sinus en x
  56.  
  57. cumul_step_lo DD 0
  58. cumul_step_hi DD 0
  59. cumul_old_lo  DD 0
  60. cumul_old_hi  DD 0
  61.  
  62.  
  63. EXTRN _BlackPal: BYTE
  64. EXTRN _WhitePal: BYTE
  65.  
  66. _DATA ENDS
  67.  
  68. ;données non initialisées
  69. ;-------------------------
  70. _BSS SEGMENT
  71.  
  72. EXTRN _FrameCounter     : WORD
  73. EXTRN _SinusTbl         : WORD  ; table sinus pour rotation (sin*256)
  74. EXTRN _StartAdr         : WORD 
  75. EXTRN _WorkAdr          : WORD
  76. EXTRN _NextAdr          : WORD
  77. EXTRN _Triple           : WORD
  78. EXTRN _SyncFlag         : WORD
  79. EXTRN _TmpPal           : BYTE
  80. EXTRN _FadeON           : WORD
  81. EXTRN _VGAcompatible    : WORD
  82. ;!!!!!!!!!! synchro avec music !!!!!!!!!!!!
  83. EXTRN _MP               : DWORD ; extern ModulePlayer * MB
  84. EXTRN _ReplayInfo       : mpInformation
  85.  
  86. EVEN
  87.  
  88.  
  89. EVEN
  90. Picseg    WORD ?        ; ptr vers segment pattern
  91. TabSeg    WORD ?        ; ptr vers segment curves table
  92. SinePtr   WORD ?        ; ptr vers sous-table
  93. Timeleft  WORD ?        ; temps restant pour execution
  94.  
  95. ;---- param pour synchro avec zizik ----
  96. EVEN
  97. DebSong  WORD ?
  98. FinSong  WORD ?
  99.  
  100.  
  101. Dest DW ?
  102. FadeFlag WORD ?        ; flag pour fading
  103. FadePtr1 WORD 2 DUP(?) ; ptr sur palette a fader
  104. FadePtr2 WORD 2 DUP(?)
  105. Delai    WORD ?
  106. Termine  WORD ?        ; flag pour terminer !!!
  107.  
  108. ;-------------
  109. ; Flags 
  110.  
  111. Anim    WORD ?
  112. RotFlag WORD ?
  113. Indep   WORD ?
  114. Sine    WORD ?
  115.  
  116. CurStep WORD ?         ; current step !!!
  117.  
  118. _BSS ENDS
  119.  
  120. ROTA_TEXT SEGMENT
  121.      PUBLIC _StartZoom
  122.      EXTRN _AveragePAL : FAR
  123.  
  124.  
  125. ; !!!! Point d'entree de l'intro !!!!
  126.  
  127. ALIGN
  128. EVEN
  129. _StartZoom PROC FAR
  130.  
  131.          push    bp                  ; bâtit le cadre de pile
  132.          mov     bp,sp
  133.          
  134.          pushad
  135.          MPUSH ds,es,fs,gs
  136.  
  137.          STARTUP
  138.  
  139. ;------- recuperer parametres sur le stack !!!! --------
  140.  
  141.          mov     ax,WORD PTR ss:[bp+6]  ; debut pos
  142.          shl     eax,14        
  143.          or      ax,WORD PTR ss:[bp+8]  ; debut row
  144.          or      ah,al
  145.          shr     eax,8
  146.          mov     DebSong,ax
  147.          mov     ax,WORD PTR ss:[bp+10] ; fin pos
  148.          shl     eax,14 
  149.          or      ax,WORD PTR ss:[bp+12] ; fin row
  150.          or      ah,al
  151.          shr     eax,8
  152.          mov     FinSong,ax
  153.          xor     eax,eax
  154. ;-------------------------------------------------------
  155.  
  156.          cmp     _VGAcompatible,0
  157.          je      @F 
  158.          push    m160x80x256c        ; set 7-mode if full VGA compatible 
  159.          jmp     FullVGA
  160. @@:      push    m320x80x256c
  161. FullVGA: call    _SetVGA
  162.          add     sp,2
  163.  
  164.          STARTUP
  165. ;--------------------------------------
  166.          call    Rotatif             ; !!!!! rotate part !!!!!
  167. ;--------------------------------------
  168.  
  169.          mov  ax,0a000h              ; clear screen
  170.          mov  es,ax
  171.          xor  eax,eax
  172.          xor  di,di
  173.          mov  cx,65536/4
  174.          rep  stosd
  175.  
  176.          MPOP ds,es,fs,gs
  177.          popad
  178.          nop
  179.  
  180.          leave                       ; restore stack
  181.                                      ; mov sp,bp + pop bp
  182.          retf 
  183.  
  184. _StartZoom ENDP
  185.  
  186. ;==============================================================================
  187. ;========================== Rotative part =====================================
  188. ;==============================================================================
  189. ALIGN
  190. EVEN
  191. Rotatif PROC NEAR
  192.  
  193.  
  194. ; Some Macros ...
  195.  
  196. COLOR MACRO lum:REQ                 ; to see the CPU time used...
  197.        MPUSH ax,dx
  198.        mov   dx,3c8h
  199.        xor   al,al
  200.        out   dx,al
  201.        inc   dl
  202.        mov   al,lum
  203.        out   dx,al
  204.        out   dx,al
  205.        out   dx,al
  206.        MPOP  ax,dx
  207.       ENDM
  208.  
  209. NEXTSTEP MACRO
  210.         LOCAL lbl1
  211.  
  212. ;------------ FrameCounter manip ------------
  213.         MPUSH  eax,ebx,ecx,edx
  214.  
  215.         mov    cx,_FrameCounter
  216.         test   cx,cx
  217.         jnz    lbl1
  218.         mov    cx,1
  219.  
  220. lbl1:   xor    eax,eax
  221.         mov    ah,cl ; frame*256
  222.        ; mov    ax,256 ;307              ; 1.2*256 = factor
  223.        ; mul    cx
  224.  
  225.         mov    ecx,cumul_step_lo   ; save old cumulated step (64 bits)
  226.         mov    cumul_old_lo,ecx
  227.         mov    ecx,cumul_step_hi
  228.         mov    cumul_old_hi,ecx   
  229.      
  230.         add    cumul_step_lo,eax   ; multiprecision
  231.         adc    cumul_step_hi,0
  232.  
  233.         mov    ecx,cumul_step_hi
  234.         mov    eax,cumul_step_lo
  235.         shrd   eax,ecx,8           ; / 256
  236.         mov    edx,cumul_old_hi
  237.         mov    ebx,cumul_old_lo
  238.         shrd   ebx,edx,8
  239.  
  240.         sub    eax,ebx
  241. ;        sbb    ecx,edx
  242.  
  243.         mov    CurStep,ax  ; CurStep = factor * FrameCounter
  244.  
  245.         mov    _FrameCounter,0
  246.  
  247.         MPOP   eax,ebx,ecx,edx
  248. ;--------------------------------------------
  249.  
  250. ENDM
  251.  
  252.  
  253. ;------------------------------------------------------------------------------
  254.  
  255.          pushad
  256.  
  257.          mov     eax,_OfsinDta         ; OFFSET in Datafile
  258.          mov     Picparam.OfsInPdf,eax
  259.          mov     ax,_DATA              ; prepare for PDFIK call 
  260.          mov     es,ax 
  261.          mov     bx,OFFSET Picparam  
  262.          pusha 
  263.          call    PDFIK_ASM             ; call function 2 (extract+alloc)
  264.          popa
  265.          mov     ax,Picparam.BufSeg ; where is the file in mem ?  
  266.          mov     Picseg,ax
  267.  
  268.          push    ds
  269.          push    es
  270.          mov     ax,Picseg
  271.          mov     ds,ax                 ; 32 bytes for Alchemy Header
  272.          mov     si,32                 ; palette offset 
  273.          mov     es,ax
  274.          mov     di,32
  275.  
  276.          mov     cx,768                ; 256*3 components
  277. @@:      lodsb
  278.          shr     al,2                  ; 8 to 6 bits conversion
  279.          stosb
  280.          dec     cx
  281.          jnz     @B
  282.  
  283.          pop     es
  284.          pop     ds
  285.  
  286.          mov     ah,48h                ; MALLOC
  287.          mov     bx,(65535 SHR 4)+1    ; memory requested
  288.          int     21h
  289.          mov     TabSeg,ax             ; Segment address returned
  290.  
  291. ; do precalculations   (calculer table des courbes !!!)
  292.  
  293.          push    es
  294.          mov     ax,TabSeg             ; my table
  295.          mov     es,ax
  296.          xor     di,di
  297.          mov     bx,0                  ; amplitude de base
  298.          mov     cx,32                 ; 32 arrays of 2048 bytes (sinus)
  299. EVEN        
  300. looper:
  301.          mov     si,OFFSET _SinusTbl   ; Sine table
  302.          push    cx
  303.          mov     cx,1024               ; 1024 valeurs/courbe
  304. @@:
  305.          lodsw
  306.          imul    bx                    ; * amplitude
  307.          mov     al,ah                 ; normaliser
  308.          mov     ah,dl
  309.          stosw                         ; sauver valeur
  310.          dec     cx                    ; loop    @B
  311.          jnz     @B
  312.          pop     cx
  313.          add     bx,8                  ; calculer amplitude suivante
  314.          dec     cx                    ; loop    looper
  315.          jnz     looper
  316.          pop     es
  317.  
  318.  
  319. ;---------------
  320.  
  321.          STARTUP
  322.  
  323. ;---- wait right position/row in tune ----
  324.  
  325. WaitPos: 
  326.          mov     _ReplayInfo.numChannels,4 ; 4 voices
  327.          
  328.          les     bx,DWORD PTR[_MP]
  329.          push    ds
  330.          push    OFFSET _ReplayInfo
  331.  
  332.          ; _MP->GetInformation(&ReplayInfo)
  333.  
  334.          call    (ModulePlayer PTR es:[bx]).GetInformation
  335.          add     sp,4
  336.  
  337.          mov     ax,_ReplayInfo.pos
  338.          shl     eax,14
  339.          or      ax,_ReplayInfo.row
  340.          or      ah,al
  341.          shr     eax,8
  342.          cmp     ax,WORD PTR[DebSong]  ; is it time ????
  343.          jb      WaitPos
  344.  
  345.          xor     eax,eax   
  346.  
  347. ;------------------------------------------
  348.  
  349.          mov     Termine,0 ; pas encore terminer !!! 
  350.          mov     Anim,0    ; pas encore animation
  351.          mov     RotFlag,0 ; pas encore rotation
  352.          mov     Indep,0   ; pas encore scale independant
  353.          mov     Sine,0    ; pas encore sinus
  354.          mov     SinePtr,0 ; 1st sinus table = 000000
  355.          mov     Xptr,128
  356.  
  357.  
  358.          mov     Angle,0
  359.          mov     Scalx,512*2  
  360.          mov     Scaly,512*2  
  361.          mov     Coordx,92 
  362.          mov     Coordy,192 
  363.          mov     Stepx,-4*2 
  364.          mov     Stepy,-4*2 
  365.  
  366.          mov     _FadeON,0 
  367.          mov     FadeFlag,0
  368.          mov     FadePtr1,OFFSET _BlackPal  ; Black to pic for the beginning !!!
  369.          mov     ax,ds
  370.          mov     FadePtr1+2,ax
  371.          mov     FadePtr2,32
  372.          mov     ax,Picseg
  373.          mov     FadePtr2+2,ax
  374. ;         mov     ax,_FrameCounter
  375. ;         mov     Delai,ax
  376.          mov     _Framecounter,0
  377.          mov     Delai,0
  378.  
  379.          cmp     _VGAcompatible,0
  380.          je      NoCompatible      ; if card doesn't support 7-mode technology
  381.  
  382. ;==================== VGA compatible code =====================
  383. ;        works in 7-mode technology --> hardware pixel doubling (fast!)
  384.  
  385.          mov     bx,_StartAdr
  386.          mov     WORD PTR[bx],Screen1   ; _StartAdr->base = 0
  387.          mov     WORD PTR[bx+2],0       ; _StartAdr->flag = false
  388.          mov     bx,_WorkAdr
  389.          mov     WORD PTR[bx],Screen2   ; _WorkAdr->base
  390.          mov     WORD PTR[bx+2],0       ; _WorkAdr->flag = false
  391.          mov     bx,_NextAdr
  392.          mov     WORD PTR[bx],Screen3   ; _NextAdr->base
  393.          mov     WORD PTR[bx+2],0       ; _NextAdr->flag = false
  394.          mov     _Triple,1              ; triple buffering
  395.          VSYNC
  396.  
  397. EVEN
  398. MainRot: ; " VSYNC "
  399.  
  400. ;***** 2nd page *****
  401. Do_a_frame:
  402.          mov  di,_WorkAdr
  403.          cmp  WORD PTR[di+2],1 ; _WorkAdr->flag true (previous _NextAdr) ?
  404.          je   NextFrame        ; then construct next frame
  405.  
  406.          mov  Dest,di          ; save pointer
  407.  
  408.          NEXTSTEP              ; calculate current step !!!!
  409.  
  410.          cmp     Anim,0
  411.          je      Fade
  412.  
  413.          mov     ax,CurStep   ; get current step !!!
  414.  
  415.          cmp     RotFlag,0
  416.          je      pasRot
  417.          add     Angle,ax     ; reupdate position, angle and scaling
  418.          add     Angle,ax
  419. pasRot:   
  420.          sub     Coordx,ax
  421.          sub     Coordx,ax
  422.          add     Coordy,ax    ; incrementer en fonction des VBLs attendues
  423.          add     Coordy,ax
  424.          mov     cx,ax        ; nombre de VBLs perdues...
  425. @@:      mov     ax,Stepx
  426.          add     Scalx,ax     ; echelle en x
  427.          mov     ax,Stepy
  428.          add     Scaly,ax     ; echelle en y
  429.          add     Yptr,6       ; pointeur sinus vertical (moving)
  430.          and     Yptr,1023
  431.          add     Xptr,4       ; pointeur sinus horizontal (scaling)
  432.          and     Xptr,1023
  433.          dec     cx           ; loop    @B
  434.          jnz     @B
  435.  
  436.          cmp     Sine,1
  437.          jne     Clip
  438.          cmp     SinePtr,63488; max reached ???
  439.          je      Clip
  440.          add     SinePtr,2048 ; if sine enabled, jump to next table
  441.  
  442. Clip:
  443.          cmp     Scalx,32     ; keep scaling in the "range"
  444.          jg      @F
  445.          neg     Stepx
  446.          cmp     Indep,0
  447.          jne     tsta
  448.          neg     Stepy
  449.          cmp     RotFlag,1
  450.          jne     Fade
  451.          mov     Indep,1      ; enable bidirectionnal scaling
  452.          add     Stepy,2      ; asymetric !!!!
  453.          jmp     Fade
  454. tsta:    cmp     RotFlag,1
  455.          jne     @F
  456.          mov     Sine,1       ; enable sinus !!! 
  457. @@:      cmp     Scalx,2048
  458.          jl      @F
  459.          mov     RotFlag,1    ; active rotations now !!!  
  460.          neg     Stepx
  461.          cmp     Indep,0
  462.          jne     @F
  463.          neg     Stepy
  464.          jmp     Fade
  465. @@:      cmp     Scaly,32
  466.          jg      @F
  467.          neg     Stepy
  468.          cmp     Indep,0
  469.          jne     tstb
  470.          neg     Stepx
  471.          cmp     RotFlag,1
  472.          jne     Fade
  473.          mov     Indep,1      ; enable bidirectionnal scaling
  474.          inc     Stepy        ; asymetric !!!!  
  475.          jmp     Fade
  476. tstb:    cmp     RotFlag,1
  477.          jne     @F
  478.          mov     Sine,1       ; enable sinus !!!
  479. @@:      cmp     Scaly,2048
  480.          jl      @F
  481.          mov     RotFlag,1    ; active rotations now !!!
  482.          neg     Stepy
  483.          cmp     Indep,0
  484.          jne     @F
  485.          neg     Stepx
  486. @@:    
  487.  
  488. Fade:
  489.          cmp     FadeFlag,255
  490.          jb     @F
  491.          cmp     Termine,1            ; Terminer si dernier fade fini
  492.          je      GoOutRot
  493.          mov     Anim,1
  494.          mov     _FadeON,0            ; no more new PAL ....
  495.          jmp     Hela
  496. @@:      mov     ax,FadeFlag          ; average Black-MyPal
  497.          push    ax
  498.          push    ds
  499.          push    OFFSET _TmpPal
  500.          mov     ax,FadePtr1+2
  501.          push    ax         
  502.          mov     ax,FadePtr1
  503.          push    ax
  504.          mov     ax,FadePtr2+2 
  505.          push    ax
  506.          mov     ax,FadePtr2
  507.          push    ax
  508.          call    _AveragePAL
  509.          add     sp,7*2
  510.          mov     _FadeON,1            ; set new PAL during VSYNC !! 
  511.          mov     cx,CurStep           ; relative to step !!!
  512.          sub     cx,Delai             ; temps chargement
  513.          mov     Delai,0              ; plus delai ....
  514.          test    cx,cx
  515.          jnz     Faddi
  516.          inc     cx
  517. Faddi:   add     FadeFlag,4           ; inc fade ..
  518.          dec     cx
  519.          jnz     Faddi
  520. Hela:      
  521.  
  522.  
  523.  
  524. ;----------- test if we must finish ... ----------
  525.  
  526.          mov     _ReplayInfo.numChannels,4 ; 4 voices
  527.          
  528.          les     bx,DWORD PTR[_MP]
  529.          push    ds
  530.          push    OFFSET _ReplayInfo
  531.  
  532.          ; _MP->GetInformation(&ReplayInfo)
  533.  
  534.          call    (ModulePlayer PTR es:[bx]).GetInformation
  535.          add     sp,4
  536.  
  537.          mov     ax,_ReplayInfo.pos
  538.          shl     eax,14
  539.          or      ax,_ReplayInfo.row
  540.          or      ah,al
  541.          shr     eax,8
  542.          cmp     ax,WORD PTR[FinSong]    ; is it time ????
  543.          jb      @F                      ; to fade off ???
  544.  
  545.          mov     Termine,1
  546.  
  547.          cmp     FadePtr2,OFFSET _WhitePal
  548.          je      @F
  549.          mov     FadeFlag,0
  550.          mov     eax,DWORD PTR[FadePtr2]
  551.          mov     DWORD PTR[FadePtr1],eax   ; fade to white !!!!
  552.          mov     ax,ds
  553.          mov     FadePtr2+2,ax
  554.          mov     FadePtr2,OFFSET _WhitePal
  555. @@:      xor     eax,eax
  556. ;--------------------------------------------------------------------
  557.  
  558.  
  559.          SHOWTIME 32
  560.  
  561.          call    Rotate_It
  562.  
  563.          mov    di,_NextAdr
  564.  
  565.          mov    bx,Dest
  566.          mov    WORD PTR[bx+2],1     ; _WorkAdr->flag = true
  567.  
  568.          SHOWTIME 0
  569.  
  570.          jmp  Nexxxt
  571.  
  572. ;******** 3rd page *********
  573. NextFrame:
  574.          mov  di,_NextAdr
  575.          cmp  WORD PTR[di+2],1 ; _NextAdr true ?
  576.          je   NextFrame
  577.     
  578. Nexxxt:
  579.          mov  Dest,di          ; save pointer
  580.  
  581.          NEXTSTEP              ; calculate current step !!!
  582.  
  583.          cmp     Anim,0
  584.          je      Fade2
  585.  
  586.          mov     ax,CurStep   ; get current step !!!
  587.  
  588.          cmp     RotFlag,0
  589.          je      pasRot2
  590.          add     Angle,ax     ; reupdate position, angle and scaling
  591.          add     Angle,ax
  592. pasRot2:
  593.          sub     Coordx,ax
  594.          sub     Coordx,ax
  595.          add     Coordy,ax    ; incrementer en fonction des VBLs attendues
  596.          add     Coordy,ax
  597.          mov     cx,ax        ; nombre de VBLs perdues...
  598. @@:      mov     ax,Stepx
  599.          add     Scalx,ax     ; echelle en x
  600.          mov     ax,Stepy
  601.          add     Scaly,ax     ; echelle en y
  602.          add     Yptr,6       ; pointeur sinus vertical (moving)
  603.          and     Yptr,1023
  604.          add     Xptr,4       ; pointeur sinus horizontal (scaling)
  605.          and     Xptr,1023
  606.          dec     cx           ; loop    @B
  607.          jnz     @B
  608.  
  609.          cmp     Sine,1
  610.          jne     Clip2
  611.          cmp     SinePtr,63488; max reached ???
  612.          je      Clip2
  613.          add     SinePtr,2048 ; if sine enabled, jump to next table
  614.  
  615. Clip2:
  616.          cmp     Scalx,32     ; keep scaling in the "range"
  617.          jg      @F
  618.          neg     Stepx
  619.          cmp     Indep,0
  620.          jne     tsta2
  621.          neg     Stepy
  622.          cmp     RotFlag,1
  623.          jne     Fade2
  624.          mov     Indep,1      ; enable bidirectionnal scaling
  625.          add     Stepy,2      ; asymetric !!!!
  626.          jmp     Fade2
  627. tsta2:   cmp     RotFlag,1
  628.          jne     @F
  629.          mov     Sine,1       ; enable sinus !!! 
  630. @@:      cmp     Scalx,2048
  631.          jl      @F
  632.          mov     RotFlag,1    ; active rotations now !!!  
  633.          neg     Stepx
  634.          cmp     Indep,0
  635.          jne     @F
  636.          neg     Stepy
  637.          jmp     Fade2
  638. @@:      cmp     Scaly,32
  639.          jg      @F
  640.          neg     Stepy
  641.          cmp     Indep,0
  642.          jne     tstb2
  643.          neg     Stepx
  644.          cmp     RotFlag,1
  645.          jne     Fade2
  646.          mov     Indep,1      ; enable bidirectionnal scaling
  647.          inc     Stepy        ; asymetric !!!!  
  648.          jmp     Fade2
  649. tstb2:   cmp     RotFlag,1
  650.          jne     @F
  651.          mov     Sine,1       ; enable sinus !!!
  652. @@:      cmp     Scaly,2048
  653.          jl      @F
  654.          mov     RotFlag,1    ; active rotations now !!!
  655.          neg     Stepy
  656.          cmp     Indep,0
  657.          jne     @F
  658.          neg     Stepx
  659. @@:    
  660.  
  661.  
  662. Fade2:
  663.          cmp     FadeFlag,255
  664.          jb      @F
  665.          cmp     Termine,1            ; Terminer si dernier fade fini ...
  666.          je      GoOutRot
  667.          mov     Anim,1
  668.          mov     _FadeON,0            ; no more new PAL ....
  669.          jmp     Hela2
  670. @@:      mov     ax,FadeFlag          ; average Black-MyPal
  671.          push    ax
  672.          push    ds
  673.          push    OFFSET _TmpPal
  674.          mov     ax,FadePtr1+2
  675.          push    ax         
  676.          mov     ax,FadePtr1
  677.          push    ax
  678.          mov     ax,FadePtr2+2 
  679.          push    ax
  680.          mov     ax,FadePtr2
  681.          push    ax
  682.          call    _AveragePAL
  683.          add     sp,7*2
  684.          mov     _FadeON,1            ; set new PAL during VSYNC !!!!   
  685.          mov     cx,CurStep           ; relative to CurStep
  686.          sub     cx,Delai             ; temps chargement
  687.          mov     Delai,0              ; plus delai ....
  688.          test    cx,cx
  689.          jnz     Faddi2
  690.          inc     cx
  691. Faddi2:  add     FadeFlag,4           ; inc fade ..
  692.          dec     cx
  693.          jnz     Faddi2
  694. Hela2:
  695.  
  696. ;----------- test if we must finish ... ----------
  697.  
  698.          mov     _ReplayInfo.numChannels,4 ; 4 voices
  699.          
  700.          les     bx,DWORD PTR[_MP]
  701.          push    ds
  702.          push    OFFSET _ReplayInfo
  703.  
  704.          ; _MP->GetInformation(&ReplayInfo)
  705.  
  706.          call    (ModulePlayer PTR es:[bx]).GetInformation
  707.          add     sp,4
  708.  
  709.          mov     ax,_ReplayInfo.pos
  710.          shl     eax,14
  711.          or      ax,_ReplayInfo.row
  712.          or      ah,al
  713.          shr     eax,8
  714.          cmp     ax,WORD PTR[FinSong]    ; is it time ????
  715.          jb      @F                      ; to fade off ???
  716.  
  717.          mov     Termine,1
  718.  
  719.  
  720.          cmp     FadePtr2,OFFSET _WhitePal
  721.          je      @F
  722.          mov     FadeFlag,0
  723.          mov     eax,DWORD PTR[FadePtr2]
  724.          mov     DWORD PTR[FadePtr1],eax   ; fade to white !!!!
  725.          mov     ax,ds
  726.          mov     FadePtr2+2,ax
  727.          mov     FadePtr2,OFFSET _WhitePal
  728. @@:      xor     eax,eax
  729. ;--------------------------------------------------------------------
  730.  
  731.  
  732.          SHOWTIME 32
  733.  
  734.          call    Rotate_It
  735.  
  736.          mov    bx,Dest
  737.          mov    WORD PTR[bx+2],1     ; _WorkAdr->flag = true
  738.  
  739.          SHOWTIME 0
  740.  
  741.          LOOP_UNTIL_KEY MainRot
  742.  
  743.          jmp     GoOutRot
  744.  
  745. ;===============================================================
  746.  
  747. ;===================== No VGA compatible code ==================
  748.  
  749. NoCompatible:  ; works in standard 320 width --> software pixel doubling (slow)
  750.  
  751.          mov     bx,_StartAdr
  752.          mov     WORD PTR[bx],Screen1   ; _StartAdr->base = 0
  753.          mov     bx,_WorkAdr
  754.          mov     WORD PTR[bx],Screen2*2 ; _WorkAdr->base
  755.          mov     WORD PTR[bx+2],0       ; _WorkAdr->flag = false
  756.          mov     _Triple,0              ; double buffering
  757.          mov     _SyncFlag,1
  758.          VSYNC
  759.  
  760. EVEN
  761. BMainRot: ; " VSYNC "
  762.  
  763. wait_for_VBL:                       ; wait for Sync Flag
  764.          cmp     _SyncFlag,1
  765.          jne      wait_for_VBL
  766.          mov     _SyncFlag,0
  767.  
  768.          NEXTSTEP                   ; calculate current step !!!
  769.  
  770.          cmp     Anim,0
  771.          je      BFade
  772.  
  773.          mov     ax,CurStep         ; get current step
  774.  
  775.          cmp     RotFlag,0
  776.          je      BpasRot
  777.          add     Angle,ax     ; reupdate position, angle and scaling
  778.          add     Angle,ax
  779. BpasRot:
  780.          sub     Coordx,ax
  781.          sub     Coordx,ax
  782.          add     Coordy,ax    ; incrementer en fonction des VBLs attendues
  783.          add     Coordy,ax
  784.          mov     cx,ax        ; nombre de VBLs perdues...
  785. @@:      mov     ax,Stepx
  786.          add     Scalx,ax     ; echelle en x
  787.          mov     ax,Stepy
  788.          add     Scaly,ax     ; echelle en y
  789.          add     Yptr,6       ; pointeur sinus vertical (moving)
  790.          and     Yptr,1023
  791.          add     Xptr,4       ; pointeur sinus horizontal (scaling)
  792.          and     Xptr,1023
  793.          dec     cx           ; loop    @B
  794.          jnz     @B
  795.  
  796.          cmp     Sine,1
  797.          jne     BClip
  798.          cmp     SinePtr,63488; max reached ???
  799.          je      BClip
  800.          add     SinePtr,2048 ; if sine enabled, jump to next table
  801.  
  802. BClip:
  803.          cmp     Scalx,32     ; keep scaling in the "range"
  804.          jg      @F
  805.          neg     Stepx
  806.          cmp     Indep,0
  807.          jne     Btsta
  808.          neg     Stepy
  809.          cmp     RotFlag,1
  810.          jne     BFade
  811.          mov     Indep,1      ; enable bidirectionnal scaling
  812.          add     Stepy,2      ; asymetric !!!!
  813.          jmp     BFade
  814. Btsta:   cmp     RotFlag,1
  815.          jne     @F
  816.          mov     Sine,1       ; enable sinus !!! 
  817. @@:      cmp     Scalx,2048
  818.          jl      @F
  819.          mov     RotFlag,1    ; active rotations now !!!  
  820.          neg     Stepx
  821.          cmp     Indep,0
  822.          jne     @F
  823.          neg     Stepy
  824.          jmp     BFade
  825. @@:      cmp     Scaly,32
  826.          jg      @F
  827.          neg     Stepy
  828.          cmp     Indep,0
  829.          jne     Btstb
  830.          neg     Stepx
  831.          cmp     RotFlag,1
  832.          jne     BFade
  833.          mov     Indep,1      ; enable bidirectionnal scaling
  834.          inc     Stepy        ; asymetric !!!!  
  835.          jmp     BFade
  836. Btstb:   cmp     RotFlag,1
  837.          jne     @F
  838.          mov     Sine,1       ; enable sinus !!!
  839. @@:      cmp     Scaly,2048
  840.          jl      @F
  841.          mov     RotFlag,1    ; active rotations now !!!
  842.          neg     Stepy
  843.          cmp     Indep,0
  844.          jne     @F
  845.          neg     Stepx
  846. @@:    
  847.  
  848. BFade:
  849.          cmp     FadeFlag,255
  850.          jb     @F
  851.          cmp     Termine,1            ; Terminer si dernier fade fini
  852.          je      GoOutRot
  853.          mov     Anim,1
  854.          mov     _FadeON,0            ; no more new PAL ....
  855.          jmp     BHela
  856. @@:      mov     ax,FadeFlag          ; average Black-MyPal
  857.          push    ax
  858.          push    ds
  859.          push    OFFSET _TmpPal
  860.          mov     ax,FadePtr1+2
  861.          push    ax         
  862.          mov     ax,FadePtr1
  863.          push    ax
  864.          mov     ax,FadePtr2+2 
  865.          push    ax
  866.          mov     ax,FadePtr2
  867.          push    ax
  868.          call    _AveragePAL
  869.          add     sp,7*2
  870.          mov     _FadeON,1            ; set new PAL during VSYNC !! 
  871.          mov     cx,CurStep           ; relative to CurStep
  872.          sub     cx,Delai             ; temps chargement
  873.          mov     Delai,0              ; plus delai ....
  874.          test    cx,cx
  875.          jnz     BFaddi
  876.          inc     cx
  877. BFaddi:  add     FadeFlag,4           ; inc fade ..
  878.          dec     cx
  879.          jnz     BFaddi
  880. BHela:
  881.  
  882. ;------------------- test if we must finish ... ---------------------
  883.  
  884.          mov     _ReplayInfo.numChannels,4 ; 4 voices
  885.          
  886.          les     bx,DWORD PTR[_MP]
  887.          push    ds
  888.          push    OFFSET _ReplayInfo
  889.  
  890.          ; _MP->GetInformation(&ReplayInfo)
  891.  
  892.          call    (ModulePlayer PTR es:[bx]).GetInformation
  893.          add     sp,4
  894.  
  895.          mov     ax,_ReplayInfo.pos
  896.          shl     eax,14
  897.          or      ax,_ReplayInfo.row
  898.          or      ah,al
  899.          shr     eax,8
  900.          cmp     ax,WORD PTR[FinSong]    ; is it time ????
  901.          jb      @F                      ; to fade off ???
  902.  
  903.          mov     Termine,1
  904.  
  905.          cmp     FadePtr2,OFFSET _WhitePal
  906.          je      @F
  907.          mov     FadeFlag,0
  908.          mov     eax,DWORD PTR[FadePtr2]
  909.          mov     DWORD PTR[FadePtr1],eax   ; fade to white !!!!
  910.          mov     ax,ds
  911.          mov     FadePtr2+2,ax
  912.          mov     FadePtr2,OFFSET _WhitePal
  913. @@:      xor     eax,eax
  914. ;--------------------------------------------------------------------
  915.  
  916.          SHOWTIME 32
  917.  
  918.          mov     di,_WorkAdr
  919.          mov     Dest,di          ; save pointer
  920.  
  921.          call    BRotate_It       ; algo-B ==> software pixel doubling
  922.  
  923.          mov    bx,_WorkAdr
  924.          mov    WORD PTR[bx+2],1     ; _WorkAdr->flag = true
  925.  
  926.          SHOWTIME 0
  927.  
  928.          LOOP_UNTIL_KEY BMainRot
  929.  
  930. ;===============================================================
  931.  
  932. GoOutRot:
  933.  
  934.         FLUSH_KEYBUF                  ; Flush keyboard buffer !!! ;-)
  935.  
  936.  
  937. ;----- EXIT -----
  938.  
  939.         mov     _FadeON,0             ; don't set PAL ...
  940.  
  941.         STARTUP
  942.         mov     ax,TabSeg             ; segment to free
  943.         mov     es,ax
  944.         mov     ah,49h                ; MFREE
  945.         int     21h
  946.  
  947.         mov     ax,Picseg             ; idem ...
  948.         mov     es,ax
  949.         mov     ah,49h
  950.         int     21h
  951.  
  952.         popad
  953.         nop
  954.         ret
  955.  
  956. Rotatif ENDP
  957.  
  958. ;==============================================================================
  959.  
  960. ;----------------- 7-mode algorithm --> hardware pixel doubling ---------------
  961. ALIGN
  962. EVEN
  963. Rotate_It PROC NEAR                   ; rotation de l'image
  964.  
  965. incx  TEXTEQU <1234h>
  966. incy  TEXTEQU <1234h>
  967. xpos  TEXTEQU <1234h>
  968. ypos  TEXTEQU <1234h>
  969. YSINE TEXTEQU <1000h>
  970.  
  971.         push    ds
  972.  
  973. ; patcher sinus vertical (moving) !!!!
  974.         push    ds
  975.         mov     si,SinePtr             ; base sinus !
  976.         add     si,Yptr                ; + offset
  977.         mov     ax,TabSeg
  978.         mov     ds,ax
  979.         mov     di,OFFSET patch_it+6   ; 1er patch !
  980.         mov     cx,Windowx/2           ; pour tous les mov al,[bx+...]
  981.         EVEN
  982. @@:     lodsw                          ; charger sinus*256
  983.         sal     ax,8
  984.         xor     al,al 
  985.         mov     cs:[di],ax             ; poker dans le code
  986.         add     di,12                  ; patcher les offsets dans le code !
  987.         lodsw
  988.         sal     ax,8
  989.         xor     al,al
  990.         mov     cs:[di],ax
  991.         add     di,13
  992.         dec     cx                     ; loop    @B
  993.         jnz     @B
  994.         pop     ds
  995.  
  996. ; patcher sinus horizontal (scaling) !!!!
  997.         push    ds
  998.         mov     si,SinePtr             ; base sinus !
  999.         add     si,Xptr                ; + offset
  1000.         mov     ax,TabSeg
  1001.         mov     ds,ax
  1002.         mov     di,OFFSET patch_it+6   ; 1er patch !
  1003.         mov     cx,Windowx/2           ; pour tous les mov al,[bx+...]
  1004. EVEN
  1005. @@:     lodsw                          ; charger sinus*256
  1006.         add     cs:[di],ax             ; poker dans le code
  1007.         add     di,12                  ; patcher les offsets dans le code !
  1008.         lodsw
  1009.         add     cs:[di],ax
  1010.         add     di,13
  1011.         dec     cx                     ; loop    @B
  1012.         jnz     @B
  1013.         pop     ds
  1014.  
  1015.  
  1016. ; rotation !!!
  1017.         xor     eax,eax
  1018.         mov     ax,Angle                ; recuperer l'angle O
  1019.         and     ax,511                  ; modulo 360
  1020.  
  1021.         movsx   ebx,_SinusTbl[eax*2]    ; sin(O)*256
  1022.         movsx   edx,Scalx               ; * facteur d'échelle en x
  1023.         imul    edx,ebx
  1024.         sar     edx,8
  1025.         mov     bp,dx                   ; bp = incy
  1026.  
  1027.         movsx   edx,Scaly               ; * facteur d'échelle en y
  1028.         imul    edx,ebx
  1029.         sar     edx,8
  1030.         mov     WORD PTR cs:[pat9+5],dx ; patch the code...
  1031.  
  1032.         movsx   ebx,_SinusTbl[eax*2+256]; -cos(O)*256
  1033.         neg     ebx                     ; cos(O)*256
  1034.         movsx   edx,Scalx               ; * facteur d'échelle en x
  1035.         imul    edx,ebx
  1036.         sar     edx,8
  1037.         mov     si,dx                   ; si = incx
  1038.  
  1039.         movsx   edx,Scaly               ; * facteur d'échelle en y
  1040.         imul    edx,ebx
  1041.         sar     edx,8
  1042.         mov     WORD PTR cs:[pat10+5],dx; patch the code...
  1043.  
  1044.         mov     ax,Coordx              ; coord. initiales
  1045.         sal     ax,8
  1046.         mov     WORD PTR cs:[posx+1],ax
  1047.         mov     ax,Coordy
  1048.         sal     ax,8
  1049.         mov     WORD PTR cs:[posy+1],ax
  1050.  
  1051. ; 2D mapping
  1052.  
  1053.         mov     ax,0a000h             ; Screen base
  1054.         mov     es,ax
  1055.         mov     di,Dest               ; offset 0 (Screen)
  1056.         mov     di,WORD PTR[di]
  1057.         shl     di,2                  ; *4
  1058.         mov     ax,PicSeg             ; Picture base
  1059.         add     ax,(768+32) SHR 4     ; skip the header+pal !!!!!
  1060.         mov     ds,ax
  1061.  
  1062.         mov     cx,Windowy            ; 80 lines
  1063. EVEN
  1064. Fill:   push    cx                    ; mov     gs,cx ; save CX
  1065. posy:   mov     dx,ypos               ; position en y*256
  1066. posx:   mov     cx,xpos               ; position en x*256
  1067.  
  1068. ; calcul d'une ligne ...
  1069. patch_it LABEL WORD
  1070.         REPT (Windowx/2)-1            ; 160 pixels width
  1071.         mov    bl,ch                  ; partie haute x
  1072.         mov    bh,dh                  ; partie haute y
  1073.         mov    al,[bx+YSINE]          ; prendre valeur sur map
  1074.         add    dx,bp                  ; increment y
  1075.         add    cx,si                  ; increment x
  1076.         mov    bl,ch                  ; partie haute x
  1077.         mov    bh,dh                  ; partie haute y
  1078.         mov    ah,[bx+YSINE]          ; prendre valeur sur map
  1079.         stosw                         ; afficher
  1080.         add    dx,bp                  ; increment y
  1081.         add    cx,si                  ; increment x
  1082.         ENDM
  1083.         mov    bl,ch
  1084.         mov    bh,dh
  1085.         mov    al,[bx+YSINE]
  1086.         add    dx,bp
  1087.         add    cx,si
  1088.         mov    bl,ch
  1089.         mov    bh,dh
  1090.         mov    ah,[bx+YSINE]
  1091.         stosw
  1092.  
  1093.  
  1094. ; passer à la ligne suivante à afficher
  1095. pat9:   add     WORD PTR cs:[posx+1],incy      ; posx + sin(O)
  1096. pat10:  sub     WORD PTR cs:[posy+1],incx      ; posy - cos(O)
  1097.  
  1098.         IF (Larg-Windowx) NE 0
  1099.           add     di,(Larg-Windowx)   ; ligne suivante...
  1100.         ENDIF
  1101.  
  1102.         pop     cx                    ; mov  cx,gs ; restore CX
  1103.         dec     cx
  1104.         jnz     Fill
  1105. @@:
  1106.  
  1107.  
  1108.         pop     ds
  1109.  
  1110.         ret
  1111.  
  1112. Rotate_It ENDP
  1113.  
  1114. ;----------- No VGA compatible algorithm --> software pixel doubling -----------
  1115. ALIGN
  1116. EVEN
  1117. BRotate_It PROC NEAR                   ; rotation de l'image
  1118.  
  1119. incx  TEXTEQU <1234h>
  1120. incy  TEXTEQU <1234h>
  1121. xpos  TEXTEQU <1234h>
  1122. ypos  TEXTEQU <1234h>
  1123. YSINE TEXTEQU <1000h>
  1124.  
  1125.         push    ds
  1126.  
  1127.  
  1128. ; patcher sinus vertical (moving) !!!!
  1129.         push    ds
  1130.         mov     si,SinePtr             ; base sinus !
  1131.         add     si,Yptr                ; + offset
  1132.         mov     ax,TabSeg
  1133.         mov     ds,ax
  1134.         mov     di,OFFSET Bpatch_it+6  ; 1er patch !
  1135.         mov     cx,Windowx             ; pour tous les mov al,[bx+...]
  1136.         EVEN
  1137. @@:     lodsw                          ; charger sinus*256
  1138.         sal     ax,8
  1139.         xor     al,al 
  1140.         mov     cs:[di],ax             ; poker dans le code
  1141.         add     di,15                  ; patcher les offsets dans le code !
  1142.         dec     cx
  1143.         jnz     @B
  1144.         pop     ds
  1145.  
  1146. ; patcher sinus horizontal (scaling) !!!!
  1147.         push    ds
  1148.         mov     si,SinePtr             ; base sinus !
  1149.         add     si,Xptr                ; + offset
  1150.         mov     ax,TabSeg
  1151.         mov     ds,ax
  1152.         mov     di,OFFSET Bpatch_it+6  ; 1er patch !
  1153.         mov     cx,Windowx             ; pour tous les mov al,[bx+...]
  1154. EVEN
  1155. @@:     lodsw                          ; charger sinus*256
  1156.         add     cs:[di],ax             ; poker dans le code
  1157.         add     di,15                  ; patcher les offsets dans le code !
  1158.         dec     cx
  1159.         jnz     @B
  1160.         pop     ds
  1161.  
  1162.  
  1163. ; rotation !!!
  1164.         xor     eax,eax
  1165.         mov     ax,Angle                ; recuperer l'angle O
  1166.         and     ax,511                  ; modulo 360
  1167.  
  1168.         movsx   ebx,_SinusTbl[eax*2]    ; sin(O)*256
  1169.         movsx   edx,Scalx               ; * facteur d'échelle en x
  1170.         imul    edx,ebx
  1171.         sar     edx,8
  1172.         mov     bp,dx                   ; bp = incy
  1173.  
  1174.         movsx   edx,Scaly               ; * facteur d'échelle en y
  1175.         imul    edx,ebx
  1176.         sar     edx,8
  1177.         mov     WORD PTR cs:[Bpat9+5],dx; patch the code...
  1178.  
  1179.         movsx   ebx,_SinusTbl[eax*2+256]; -cos(O)*256
  1180.         neg     ebx                     ; cos(O)*256
  1181.         movsx   edx,Scalx               ; * facteur d'échelle en x
  1182.         imul    edx,ebx
  1183.         sar     edx,8
  1184.         mov     si,dx                   ; si = incx
  1185.  
  1186.         movsx   edx,Scaly               ; * facteur d'échelle en y
  1187.         imul    edx,ebx
  1188.         sar     edx,8
  1189.         mov     WORD PTR cs:[Bpat10+5],dx; patch the code...
  1190.  
  1191.         mov     ax,Coordx              ; coord. initiales
  1192.         sal     ax,8
  1193.         mov     WORD PTR cs:[Bposx+1],ax
  1194.         mov     ax,Coordy
  1195.         sal     ax,8
  1196.         mov     WORD PTR cs:[Bposy+1],ax
  1197.  
  1198. ; 2D mapping
  1199.  
  1200.         mov     ax,0a000h             ; Screen base
  1201.         mov     es,ax
  1202.         mov     di,Dest               ; offset 0 (Screen)
  1203.         mov     di,WORD PTR[di]
  1204.         shl     di,2                  ; *4
  1205.         mov     ax,PicSeg             ; Picture base
  1206.         add     ax,(768+32) SHR 4     ; skip the header+pal !!!!!
  1207.         mov     ds,ax
  1208.  
  1209.         mov     cx,Windowy            ; 80 lines
  1210. EVEN
  1211. BFill:  push    cx                    ; mov     gs,cx ; save CX
  1212. Bposy:  mov     dx,ypos               ; position en y*256
  1213. Bposx:  mov     cx,xpos               ; position en x*256
  1214.  
  1215.  
  1216. ; calcul d'une ligne ...
  1217. Bpatch_it LABEL WORD
  1218.         REPT (Windowx)-1              ; 160 pixels width
  1219.         mov    bl,ch                  ; partie haute x
  1220.         mov    bh,dh                  ; partie haute y
  1221.         mov    al,[bx+YSINE]          ; prendre valeur sur map
  1222.         mov    ah,al                  ; doubler taille
  1223.         stosw                         ; afficher
  1224.         add    dx,bp                  ; increment y
  1225.         add    cx,si                  ; increment x
  1226.         ENDM
  1227.         mov    bl,ch
  1228.         mov    bh,dh
  1229.         mov    al,[bx+YSINE]
  1230.         mov    ah,al
  1231.         stosw
  1232.  
  1233.  
  1234. ; passer à la ligne suivante à afficher
  1235. Bpat9:  add     WORD PTR cs:[Bposx+1],incy      ; posx + sin(O)
  1236. Bpat10: sub     WORD PTR cs:[Bposy+1],incx      ; posy - cos(O)
  1237.  
  1238.         IF (Larg-Windowx) NE 0
  1239.           add     di,(Larg-Windowx)*2 ; ligne suivante...
  1240.         ENDIF
  1241.  
  1242.         pop     cx                    ; mov  cx,gs ; restore CX
  1243.         dec     cx
  1244.         jnz     BFill
  1245. @@:
  1246.  
  1247.  
  1248.         pop     ds
  1249.  
  1250.         ret
  1251.  
  1252. BRotate_It ENDP
  1253.  
  1254.  
  1255. ;==============================================================================
  1256.  
  1257. ROTA_TEXT ENDS
  1258.  
  1259.      END
  1260.  
  1261.